PROJECT(Utopia)

CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5)

OPTION(IPOD_PLUGIN "Build the iPod plugin" ON)
OPTION(IPOD_PLUGIN_STATIC "Build the iPod plugin as a static plugin" OFF)

OPTION(BUILD_UTOPIALYRICS "Build the Utopia Lyrics application" ON)

SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

#
# DEPENDENCIES
#
MESSAGE("** Checking Dependencies **")
INCLUDE(UsePkgConfig)

# Qt 4.3.x
SET(QT_USE_QTSQL TRUE)
SET(QT_USE_QTXML TRUE)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})

# zlib
INCLUDE(FindZLIB)
IF(ZLIB_FOUND)
	MESSAGE("-- Found zlib")
ELSE(ZLIB_FOUND)
	MESSAGE(FATAL_ERROR "zlib not found! You need to fix this!")
ENDIF(ZLIB_FOUND)

# vorbis
PKGCONFIG(vorbis VORBIS_INCLUDE_DIR VORBIS_LINK_DIR VORBIS_LINK_FLAGS VORBIS_CFLAGS)
IF(DEFINED VORBIS_INCLUDE_DIR)
	MESSAGE("-- Found vorbis")
ELSE(DEFINED VORBIS_INCLUDE_DIR)
	MESSAGE(FATAL_ERROR "vorbis not found! You need to fix this!")
ENDIF(DEFINED VORBIS_INCLUDE_DIR)

# vorbisfile
PKGCONFIG(vorbisfile VORBISFILE_INCLUDE_DIR VORBISFILE_LINK_DIR VORBISFILE_LINK_FLAGS VORBISFILE_CFLAGS)
IF(DEFINED VORBISFILE_INCLUDE_DIR)
	MESSAGE("-- Found vorbisfile")
ELSE(DEFINED VORBISFILE_INCLUDE_DIR)
	MESSAGE(FATAL_ERROR "vorbisfile not found! You need to fix this!")
ENDIF(DEFINED VORBISFILE_INCLUDE_DIR)

# ogg
PKGCONFIG(ogg OGG_INCLUDE_DIR OGG_LINK_DIR OGG_LINK_FLAGS OGG_CFLAGS)
IF(DEFINED OGG_INCLUDE_DIR)
	MESSAGE("-- Found ogg")
ELSE(DEFINED OGG_INCLUDE_DIR)
	MESSAGE(FATAL_ERROR "ogg not found! You need to fix this!")
ENDIF(DEFINED OGG_INCLUDE_DIR)

# wavpack
PKGCONFIG(wavpack WAVPACK_INCLUDE_DIR WAVPACK_LINK_DIR WAVPACK_LINK_FLAGS WAVPACK_CFLAGS)
IF(DEFINED WAVPACK_INCLUDE_DIR)
	MESSAGE("-- Found wavpack")
ELSE(DEFINED WAVPACK_INCLUDE_DIR)
	MESSAGE(FATAL_ERROR "wavpack not found! You need to fix this!")
ENDIF(DEFINED WAVPACK_INCLUDE_DIR)

# ALSA
IF(UNIX)
  PKGCONFIG(alsa ALSA_INCLUDE_DIR ALSA_LIB_DIR ALSA_LD_FLAGS ALSA_CPP_FLAGS)
  IF(DEFINED ALSA_INCLUDE_DIR)
    MESSAGE("-- Found ALSA")
  ELSE(DEFINED ALSA_INCLUDE_DIR)
    MESSAGE(FATAL_ERROR "ALSA not found! You need to fix this!")
  ENDIF(DEFINED ALSA_INCLUDE_DIR)
ENDIF(UNIX)

#
# SETUP LIBRARY COMPILE PATHS
#
SET(UTOPIADB_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
SET(UTOPIADB_LINK_DIR ${CMAKE_BINARY_DIR}/libutopiadb/src)
SET(UTOPIADB_LINK_FLAGS -L${UTOPIADB_LINK_DIR}/ -lutopiadb)
SET(UTOPIADB_CFLAGS -I${UTOPIADB_INCLUDE_DIR})

ADD_SUBDIRECTORY(libutopiadb)
ADD_SUBDIRECTORY(libutopiaplayer)
ADD_SUBDIRECTORY(utopiaplayer)

IF(BUILD_UTOPIALYRICS)
	#ADD_SUBDIRECTORY(utopialyrics)
ENDIF(BUILD_UTOPIALYRICS)

ADD_SUBDIRECTORY(utopiablockbrowser)
ADD_SUBDIRECTORY(utopiatagger)
ADD_SUBDIRECTORY(plugins)
